<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">


<ui:composition template="/templates/templateProfessor.xhtml">
	<ui:define name="conteudo">
		<h:panelGrid columns="2">
			<h:outputText value="Horário: " />
			<h:outputText value="#{mBGerenciarAvaliacao.avaliacao.aula.horario}" />
			<h:outputText value="Sala: " />
			<h:outputText
				value="#{mBGerenciarAvaliacao.avaliacao.aula.sala.nome}" />
			<h:outputText value="Disciplina: " />
			<h:outputText
				value="#{mBGerenciarAvaliacao.avaliacao.aula.disciplina.nome}" />
		</h:panelGrid>

		<h:form>
			<p:dataTable var="avaliacao"
				value="#{mBGerenciarAvaliacao.avaliacoes}" paginator="true" rows="5"
				emptyMessage="Nenhuma avaliação cadastrada na turma">
				<p:column headerText="Data" filterBy="#{avaliacao.dataFormatada}"
					filterMatchMode="contains">
					<h:outputText value="#{avaliacao.dataFormatada}" />
				</p:column>

				<p:column headerText="Descrição" filterBy="#{avaliacao.descricao}"
					filterMatchMode="contains">
					<h:outputText value="#{avaliacao.descricao}" />
				</p:column>

				<p:column headerText="Peso" filterBy="#{avaliacao.peso}"
					filterMatchMode="contains">
					<h:outputText value="#{avaliacao.peso}" />
				</p:column>

				<p:column headerText="Ação">
					<p:commandButton value="Inserir notas" action="#{mBGerenciarAvaliacao.irInserirNota}" ajax="false">
						<f:setPropertyActionListener
							target="#{mBGerenciarAvaliacao.avaliacao}" value="#{avaliacao}" />
					</p:commandButton>
					<p:commandButton value="Editar notas" action="#{mBRedirect.redirecionar}">
						<f:setPropertyActionListener target="#{mBRedirect.redirecionamento}" value="/educacao/pages/professor/turma/editarNotas.jsf"/>
						<f:setPropertyActionListener
							target="#{mBEditarDesempenho.avaliacao}" value="#{avaliacao}" />
					</p:commandButton>
					<p:commandButton value="Editar" ajax="false"
						action="#{mBGerenciarAvaliacao.irEditar}">
						<f:setPropertyActionListener
							target="#{mBGerenciarAvaliacao.avaliacao}" value="#{avaliacao}" />
					</p:commandButton>
				</p:column>

			</p:dataTable>
			</h:form>
			<h:form>
			
			<p:panel header="Avaliação">
				<h:panelGrid columns="2">
					<h:outputText value="Data da Avaliacao" />
					<p:calendar value="#{mBGerenciarAvaliacao.data}" size="8" pattern="dd/MM/yyyy" required="true" requiredMessage="Insira a data da avaliação"/>
					<h:outputText value="Descricao" />
					<p:inputText value="#{mBGerenciarAvaliacao.avaliacao.descricao}" required="true" requiredMessage="Insira a descrição da avaliação" size="50"/>
					<h:outputText value="Peso" />
					<p:inputText value="#{mBGerenciarAvaliacao.avaliacao.peso}" required="true" requiredMessage="Insira um peso" size="3" validatorMessage="O peso da avaliação deve estar entre 0 e 10">
						<f:validateLongRange maximum="10" minimum="0"/>
					</p:inputText>
					
					<p:commandButton rendered="#{!mBGerenciarAvaliacao.editavel}" value="Cadastrar"
						action="#{mBGerenciarAvaliacao.cadastrar}" ajax="false" />
					<p:commandButton rendered="#{mBGerenciarAvaliacao.editavel}" value="Editar" ajax="false" action="#{mBGerenciarAvaliacao.editar}"/>
					<p:commandButton value="Cancelar" ajax="false" action="#{mBGerenciarAvaliacao.limpar}" onclick="form.reset()"/>
				</h:panelGrid>
			</p:panel>

		</h:form>
	</ui:define>
</ui:composition>
</html>